#!/bin/bash
while true # 输入循环
do
    read -p "Please input your name:" name    # 交互式输入
    echo "$name"|grep -E -q -w "^exit|^quit" && exit # 定义退出码
    echo "$name"|grep -E -q -w "[a-zA-Z]+" || continue # 非字母则继续输入循环
    [ ${#name} -eq 0 ] && continue # 为空继续输入循环
    grep -E -w "$name" random.list 2>/dev/null && continue # 内容已存在则继续输入循环	
    while true # 随机数循环
    do
        random=$(awk 'BEGIN{srand();val=int(rand()*100);print val}') # 产生随机数
        grep -E -w -q "$random" random.list 2>/dev/null && continue # 随机数存在则继续随机数循环产生新随机数
        printf "$name\t$random\n"
        printf "$name\t$random\n" >> random.list && break # 保存输入和随机数
    done
done
